var e = require("../template/picker-template/class/ParseChe-class"), t = require("../template/picker-chepai-template/class/PickerChepai-class"), a = require("../../../../utils/checkData.js"), i = require("../../../../utils/util.js"), c = (new a.Check(), 
getApp());

Page({
    data: {
        brandId: "",
        color: "",
        chepai: "苏",
        zimu: "A",
        date: 0,
        chenum: "",
        isShowPicker: !1
    },
    onLoad: function(a) {
        void 0 !== a.state && 0 == a.state && wx.showToast({
            title: "请您先添加个人车辆",
            icon: "none",
            duration: 2e3
        }), new t.PickerChepai(this), new e.ParseChe(this);
    },
    submit: function(e) {
        var t = this.data, a = this, n = {
            chepai: t.chepai + t.zimu + t.chenum,
            chenum: t.chenum,
            car: t.car,
            color: t.color,
            date: t.date,
            brandId: t.brandId
        }, o = this.checkPostData(n);
        if (1 != o) return wx.showModal({
            title: "警告",
            content: o
        }), 0;
        if ("number" != typeof n.date) {
            var s = parseInt(n.date.replace("-", ""));
            a.setData({
                date: s
            });
        }
        i.request(c, "wx/car/add", "POST", {
            token: c.globalData.token,
            brandId: a.data.brandId,
            carNo: n.chepai,
            color: n.color,
            buyDate: a.data.date
        }, function(e) {
            e.state ? (wx.showModal({
                content: "成功"
            }), setTimeout(function() {
                wx.navigateBack();
            }, 1500)) : wx.showModal({
                content: e.message
            });
        }, function(e) {});
    },
    checkPostData: function(e) {
        return "" != e.chenum || "请填写车牌";
    },
    getColor: function(e) {
        this.setData({
            color: e.detail.value
        });
    },
    getCheNum: function(e) {
        this.setData({
            chenum: e.detail.value
        });
    },
    bindDateChange: function(e) {
        this.setData({
            date: e.detail.value
        });
    }
});